/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modulemaker;

/**
 *
 * @author takao
 */
public class Column {

  private String name;
  private Column.Type type;
  private Column.Contraint[] constraints;

  public Column(String name, Type type) {
    this.name = name;
    this.type = type;
    this.constraints = null;
  }

  public Column(String name, Type type, Contraint... contraints) {
    this.name = name;
    this.type = type;
    this.constraints = contraints;
  }

  public String getName() {
    return name;
  }

  public Type getType() {
    return type;
  }

  public static enum Type {

    STRING,
    INTEGER,
    FLOAT,
    DATE,
    FOREIGN_KEY,
    PRIMARY_KEY,
    BOOLEAN
  }

  public static enum Contraint {

    NOT_NULL,
    DEFAULT;
    private String value;

    public String value() {
      return value;
    }

    public Contraint value(String value) {
      this.value = value;
      return this;
    }
  }

  public boolean is(String contraintName) {
    if (constraints == null) {
      return false;
    }
    
    for (int i = 0; i < constraints.length; i++) {
      if (constraints[i].toString().equals(contraintName)) {
        return true;
      }
    }
    return false;
  }
}
